package week1exercises;

public class Diamond {

    public static String isoscelesTriangle(int n) {
        String retVal = "";
        if (n > 0)
            for (int i = 0; i < n; i++)
                retVal = retVal.concat(Triangle.horizontalLine(n-i-1, " ")).concat(Triangle.horizontalLine(2*i+1)).concat("\n");

        return retVal;
    }

    public static String diamond(int n) {
        return diamondWithName(n, Triangle.horizontalLine(2*n-1));
    }

    public static String diamondWithName(int n, String name) {
        String retVal = "";
        if (n > 0) {
            for (int i = n; i > 0; i--) {
                if (i == n)
                    retVal = name.concat("\n");
                else {
                    String nextLine = Triangle.horizontalLine(n-i, " ").concat(Triangle.horizontalLine(2*i-1)).concat("\n");
                    retVal = nextLine.concat(retVal).concat(nextLine);
                }

            }
        }
        return retVal;
    }
}
